package com.oocl.batchdata.util;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;

import com.oocl.batchdata.pojo.Customer;

public class FormatPrinter {
	
	public static void printTable(Collection<Customer> customerList, OutputStream out) {
		try {
			out.write("id\tname\tsex\tbirthday\temail\n".getBytes());
			for (Customer customer : customerList) {
				out.write((customer.toString() + "\n").getBytes());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

	public static void printXML(Collection<Customer> customerList, OutputStream out) {
		try {
			out.write("<customers>\n".getBytes());
			for (Customer customer : customerList) {
				out.write((customer.toXMLString() + "\n").getBytes());
			}
			out.write("</customers>\n".getBytes());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
